@@ -69,20 +69,20 @@ end |
||
69 | 69 |
|
70 | 70 |
require 'mini_magick' |
71 | 71 |
|
72 |
-def convert_image(source, target, width: nil, round: false) |
|
72 |
+def convert_image(source, target, options = {}) # width: nil, round: false |
|
73 | 73 |
ext = target[/(?<=\.)[^.]+\z/] || 'png' |
74 | 74 |
original = MiniMagick::Image.open(source) |
75 | 75 |
|
76 | 76 |
result = original |
77 | 77 |
result.format ext |
78 | 78 |
|
79 |
- if width |
|
79 |
+ if width = options[:width] |
|
80 | 80 |
result.thumbnail '%1$dx%1$d>' % width |
81 | 81 |
else |
82 | 82 |
width = result[:width] |
83 | 83 |
end |
84 | 84 |
|
85 |
- if round |
|
85 |
+ if options[:round] |
|
86 | 86 |
radius = (Rational(80, 512) * width).round |
87 | 87 |
|
88 | 88 |
mask = MiniMagick::Image.create(ext) { |tmp| result.write(tmp) } |
@@ -100,5 +100,6 @@ def convert_image(source, target, width: nil, round: false) |
||
100 | 100 |
end |
101 | 101 |
end |
102 | 102 |
|
103 |
+ result.strip |
|
103 | 104 |
result.write(target) |
104 | 105 |
end |
@@ -8,30 +8,30 @@ |
||
8 | 8 |
"density": "0.75" |
9 | 9 |
}, |
10 | 10 |
{ |
11 |
- "src": "/android-chrome-48x48.png", |
|
12 |
- "sizes": "48x48", |
|
13 |
- "type": "image/png", |
|
14 |
- "density": "1.0" |
|
15 |
- }, |
|
16 |
- { |
|
17 | 11 |
"src": "/android-chrome-72x72.png", |
18 | 12 |
"sizes": "72x72", |
19 | 13 |
"type": "image/png", |
20 | 14 |
"density": "1.5" |
21 | 15 |
}, |
22 | 16 |
{ |
23 |
- "src": "/android-chrome-96x96.png", |
|
24 |
- "sizes": "96x96", |
|
25 |
- "type": "image/png", |
|
26 |
- "density": "2.0" |
|
27 |
- }, |
|
28 |
- { |
|
29 | 17 |
"src": "/android-chrome-144x144.png", |
30 | 18 |
"sizes": "144x144", |
31 | 19 |
"type": "image/png", |
32 | 20 |
"density": "3.0" |
33 | 21 |
}, |
34 | 22 |
{ |
23 |
+ "src": "/android-chrome-48x48.png", |
|
24 |
+ "sizes": "48x48", |
|
25 |
+ "type": "image/png", |
|
26 |
+ "density": "1.0" |
|
27 |
+ }, |
|
28 |
+ { |
|
29 |
+ "src": "/android-chrome-96x96.png", |
|
30 |
+ "sizes": "96x96", |
|
31 |
+ "type": "image/png", |
|
32 |
+ "density": "2.0" |
|
33 |
+ }, |
|
34 |
+ { |
|
35 | 35 |
"src": "/android-chrome-192x192.png", |
36 | 36 |
"sizes": "192x192", |
37 | 37 |
"type": "image/png", |